home *** CD-ROM | disk | FTP | other *** search
/ Digital Background Bonanza / Digital Background Bonanza - Disc 1.iso / pc / DBB1.swf / scripts / __Packages / mx / controls / ComboBase.as < prev    next >
Encoding:
Text File  |  2007-03-09  |  9.6 KB  |  328 lines

  1. class mx.controls.ComboBase extends mx.core.UIComponent
  2. {
  3.    var getValue;
  4.    var boundingBox_mc;
  5.    var downArrow_mc;
  6.    var onDownArrow;
  7.    var trackAsMenuWas;
  8.    var onPressWas;
  9.    var onDragOutWas;
  10.    var onDragOverWas;
  11.    var border_mc;
  12.    var __border;
  13.    var text_mc;
  14.    var oldOnSetFocus;
  15.    var oldOnKillFocus;
  16.    var focusTextField;
  17.    var __width;
  18.    var __height;
  19.    static var mixIt1 = mx.controls.listclasses.DataSelector.Initialize(mx.controls.ComboBase);
  20.    static var symbolName = "ComboBase";
  21.    static var symbolOwner = mx.controls.ComboBase;
  22.    static var version = "2.0.2.126";
  23.    var _editable = false;
  24.    var downArrowUpName = "ScrollDownArrowUp";
  25.    var downArrowDownName = "ScrollDownArrowDown";
  26.    var downArrowOverName = "ScrollDownArrowOver";
  27.    var downArrowDisabledName = "ScrollDownArrowDisabled";
  28.    var wrapDownArrowButton = true;
  29.    var DSgetValue = mx.controls.listclasses.DataSelector.prototype.getValue;
  30.    var multipleSelection = false;
  31.    function ComboBase()
  32.    {
  33.       super();
  34.       this.getValue = this._getValue;
  35.    }
  36.    function init()
  37.    {
  38.       super.init();
  39.       this.tabEnabled = !this._editable;
  40.       this.tabChildren = this._editable;
  41.       this.boundingBox_mc._visible = false;
  42.       this.boundingBox_mc._width = this.boundingBox_mc._height = 0;
  43.    }
  44.    function createChildren()
  45.    {
  46.       var _loc3_ = new Object();
  47.       _loc3_.styleName = this;
  48.       if(this.downArrow_mc == undefined)
  49.       {
  50.          _loc3_.falseUpSkin = this.downArrowUpName;
  51.          _loc3_.falseOverSkin = this.downArrowOverName;
  52.          _loc3_.falseDownSkin = this.downArrowDownName;
  53.          _loc3_.falseDisabledSkin = this.downArrowDisabledName;
  54.          _loc3_.validateNow = true;
  55.          _loc3_.tabEnabled = false;
  56.          this.createClassObject(mx.controls.SimpleButton,"downArrow_mc",19,_loc3_);
  57.          this.downArrow_mc.buttonDownHandler = this.onDownArrow;
  58.          this.downArrow_mc.useHandCursor = false;
  59.          this.downArrow_mc.onPressWas = this.downArrow_mc.onPress;
  60.          this.downArrow_mc.onPress = function()
  61.          {
  62.             this.trackAsMenuWas = this.trackAsMenu;
  63.             this.trackAsMenu = true;
  64.             if(!this._editable)
  65.             {
  66.                this._parent.text_mc.trackAsMenu = this.trackAsMenu;
  67.             }
  68.             this.onPressWas();
  69.          };
  70.          this.downArrow_mc.onDragOutWas = this.downArrow_mc.onDragOut;
  71.          this.downArrow_mc.onDragOut = function()
  72.          {
  73.             this.trackAsMenuWas = this.trackAsMenu;
  74.             this.trackAsMenu = false;
  75.             if(!this._editable)
  76.             {
  77.                this._parent.text_mc.trackAsMenu = this.trackAsMenu;
  78.             }
  79.             this.onDragOutWas();
  80.          };
  81.          this.downArrow_mc.onDragOverWas = this.downArrow_mc.onDragOver;
  82.          this.downArrow_mc.onDragOver = function()
  83.          {
  84.             this.trackAsMenu = this.trackAsMenuWas;
  85.             if(!this._editable)
  86.             {
  87.                this._parent.text_mc.trackAsMenu = this.trackAsMenu;
  88.             }
  89.             this.onDragOverWas();
  90.          };
  91.       }
  92.       if(this.border_mc == undefined)
  93.       {
  94.          _loc3_.tabEnabled = false;
  95.          this.createClassObject(_global.styles.rectBorderClass,"border_mc",17,_loc3_);
  96.          this.border_mc.move(0,0);
  97.          this.__border = this.border_mc;
  98.       }
  99.       _loc3_.borderStyle = "none";
  100.       _loc3_.readOnly = !this._editable;
  101.       _loc3_.tabEnabled = this._editable;
  102.       if(this.text_mc == undefined)
  103.       {
  104.          this.createClassObject(mx.controls.TextInput,"text_mc",18,_loc3_);
  105.          this.text_mc.move(0,0);
  106.          this.text_mc.addEnterEvents();
  107.          this.text_mc.enterHandler = this._enterHandler;
  108.          this.text_mc.changeHandler = this._changeHandler;
  109.          this.text_mc.oldOnSetFocus = this.text_mc.onSetFocus;
  110.          this.text_mc.onSetFocus = function()
  111.          {
  112.             this.oldOnSetFocus();
  113.             this._parent.onSetFocus();
  114.          };
  115.          this.text_mc.restrict = "^\x1b";
  116.          this.text_mc.oldOnKillFocus = this.text_mc.onKillFocus;
  117.          this.text_mc.onKillFocus = function(n)
  118.          {
  119.             this.oldOnKillFocus(n);
  120.             this._parent.onKillFocus(n);
  121.          };
  122.          this.text_mc.drawFocus = function(b)
  123.          {
  124.             this._parent.drawFocus(b);
  125.          };
  126.          delete this.text_mc.borderStyle;
  127.       }
  128.       this.focusTextField = this.text_mc;
  129.       this.text_mc.owner = this;
  130.       this.layoutChildren(this.__width,this.__height);
  131.    }
  132.    function onKillFocus()
  133.    {
  134.       super.onKillFocus();
  135.       Key.removeListener(this.text_mc);
  136.       this.getFocusManager().defaultPushButtonEnabled = true;
  137.    }
  138.    function onSetFocus()
  139.    {
  140.       super.onSetFocus();
  141.       this.getFocusManager().defaultPushButtonEnabled = false;
  142.       Key.addListener(this.text_mc);
  143.    }
  144.    function setFocus()
  145.    {
  146.       if(this._editable)
  147.       {
  148.          Selection.setFocus(this.text_mc);
  149.       }
  150.       else
  151.       {
  152.          Selection.setFocus(this);
  153.       }
  154.    }
  155.    function setSize(w, h, noEvent)
  156.    {
  157.       super.setSize(w,h != undefined ? h : this.height,noEvent);
  158.    }
  159.    function setEnabled(enabledFlag)
  160.    {
  161.       super.setEnabled(enabledFlag);
  162.       this.downArrow_mc.enabled = enabledFlag;
  163.       this.text_mc.enabled = enabledFlag;
  164.    }
  165.    function setEditable(e)
  166.    {
  167.       this._editable = e;
  168.       if(this.wrapDownArrowButton == false)
  169.       {
  170.          if(e)
  171.          {
  172.             this.border_mc.borderStyle = "inset";
  173.             this.text_mc.borderStyle = "inset";
  174.             mx.controls.ComboBase.symbolName = "ComboBox";
  175.             this.invalidateStyle();
  176.          }
  177.          else
  178.          {
  179.             this.border_mc.borderStyle = "comboNonEdit";
  180.             this.text_mc.borderStyle = "dropDown";
  181.             mx.controls.ComboBase.symbolName = "DropDown";
  182.             this.invalidateStyle();
  183.          }
  184.       }
  185.       this.tabEnabled = !e;
  186.       this.tabChildren = e;
  187.       this.text_mc.tabEnabled = e;
  188.       if(e)
  189.       {
  190.          delete this.text_mc.onPress;
  191.          delete this.text_mc.onRelease;
  192.          delete this.text_mc.onReleaseOutside;
  193.          delete this.text_mc.onDragOut;
  194.          delete this.text_mc.onDragOver;
  195.          delete this.text_mc.onRollOver;
  196.          delete this.text_mc.onRollOut;
  197.       }
  198.       else
  199.       {
  200.          this.text_mc.onPress = function()
  201.          {
  202.             this._parent.downArrow_mc.onPress();
  203.          };
  204.          this.text_mc.onRelease = function()
  205.          {
  206.             this._parent.downArrow_mc.onRelease();
  207.          };
  208.          this.text_mc.onReleaseOutside = function()
  209.          {
  210.             this._parent.downArrow_mc.onReleaseOutside();
  211.          };
  212.          this.text_mc.onDragOut = function()
  213.          {
  214.             this._parent.downArrow_mc.onDragOut();
  215.          };
  216.          this.text_mc.onDragOver = function()
  217.          {
  218.             this._parent.downArrow_mc.onDragOver();
  219.          };
  220.          this.text_mc.onRollOver = function()
  221.          {
  222.             this._parent.downArrow_mc.onRollOver();
  223.          };
  224.          this.text_mc.onRollOut = function()
  225.          {
  226.             this._parent.downArrow_mc.onRollOut();
  227.          };
  228.          this.text_mc.useHandCursor = false;
  229.       }
  230.    }
  231.    function get editable()
  232.    {
  233.       return this._editable;
  234.    }
  235.    function set editable(e)
  236.    {
  237.       this.setEditable(e);
  238.    }
  239.    function _getValue()
  240.    {
  241.       return !this._editable ? this.DSgetValue() : this.text_mc.getText();
  242.    }
  243.    function draw()
  244.    {
  245.       this.downArrow_mc.draw();
  246.       this.border_mc.draw();
  247.    }
  248.    function size()
  249.    {
  250.       this.layoutChildren(this.__width,this.__height);
  251.    }
  252.    function setTheme(t)
  253.    {
  254.       this.downArrowUpName = t + "downArrow" + "Up_mc";
  255.       this.downArrowDownName = t + "downArrow" + "Down_mc";
  256.       this.downArrowDisabledName = t + "downArrow" + "Disabled_mc";
  257.    }
  258.    function get text()
  259.    {
  260.       return this.text_mc.getText();
  261.    }
  262.    function set text(t)
  263.    {
  264.       this.setText(t);
  265.    }
  266.    function setText(t)
  267.    {
  268.       this.text_mc.setText(t);
  269.    }
  270.    function get textField()
  271.    {
  272.       return this.text_mc;
  273.    }
  274.    function get restrict()
  275.    {
  276.       return this.text_mc.restrict;
  277.    }
  278.    function set restrict(w)
  279.    {
  280.       this.text_mc.restrict = w;
  281.    }
  282.    function invalidateStyle()
  283.    {
  284.       this.downArrow_mc.invalidateStyle();
  285.       this.text_mc.invalidateStyle();
  286.       this.border_mc.invalidateStyle();
  287.    }
  288.    function layoutChildren(w, h)
  289.    {
  290.       if(this.downArrow_mc == undefined)
  291.       {
  292.          return undefined;
  293.       }
  294.       if(this.wrapDownArrowButton)
  295.       {
  296.          var _loc2_ = this.border_mc.borderMetrics;
  297.          this.downArrow_mc._width = this.downArrow_mc._height = h - _loc2_.top - _loc2_.bottom;
  298.          this.downArrow_mc.move(w - this.downArrow_mc._width - _loc2_.right,_loc2_.top);
  299.          this.border_mc.setSize(w,h);
  300.          this.text_mc.setSize(w - this.downArrow_mc._width,h);
  301.       }
  302.       else
  303.       {
  304.          this.downArrow_mc.move(w - this.downArrow_mc._width,0);
  305.          this.border_mc.setSize(w - this.downArrow_mc.width,h);
  306.          this.text_mc.setSize(w - this.downArrow_mc._width,h);
  307.          this.downArrow_mc._height = this.height;
  308.       }
  309.    }
  310.    function _changeHandler(obj)
  311.    {
  312.    }
  313.    function _enterHandler(obj)
  314.    {
  315.       var _loc2_ = this._parent;
  316.       obj.target = _loc2_;
  317.       _loc2_.dispatchEvent(obj);
  318.    }
  319.    function get tabIndex()
  320.    {
  321.       return this.text_mc.tabIndex;
  322.    }
  323.    function set tabIndex(w)
  324.    {
  325.       this.text_mc.tabIndex = w;
  326.    }
  327. }
  328.